#include<iostream>
#include<set>
using namespace std;

struct person {
	int h;
	int w;
	int age;
	person(int _h, int _w, int _age) {
		h = _h;
		w = _w;
		age = _age;
	}
	bool operator <(const person &rhs) const {
		if(h != rhs.h) {
			return h < rhs.h; 
		}
		if(w != rhs.w) {
			return w < rhs.w;
		}
		if(age != rhs.age) {
			return age < rhs.age;
		}
	}
};

set<person> p;

int main(void) {
	int n, m, h, w, a;
	cin >> n >> m;
	for(int i = 0; i < n; i++) {
		cin >> h >> w >> a;
		p.insert(person(h, w, a));
	}
	for(int i = 0; i < m; i++) {
		cin >> h >> w >> a;
		if(p.count(person(h, w, a))) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
 	}
	return 0;
}
